package com.onesports.intelligent.k12.polarlight.controller.organization.index;

import com.onesports.intelligent.k12.polarlight.common.utils.ResultUtil;
import com.onesports.intelligent.k12.polarlight.constant.ApiPathConstants;
import com.onesports.intelligent.k12.polarlight.domain.dto.index.HomeDTO;
import com.onesports.intelligent.k12.polarlight.domain.vo.course.CourseScheduleDetailVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.report.OrganizationHomePageVO;
import com.onesports.intelligent.k12.polarlight.security.SecurityUtils;
import com.onesports.intelligent.k12.polarlight.service.course.CourseScheduleService;
import com.onesports.intelligent.k12.polarlight.service.index.OrganizationHomePageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author Wsy
 **/
@Api(tags = "工作台")
@RequestMapping(ApiPathConstants.WORKBENCH)
@RequiredArgsConstructor
@RestController
@PreAuthorize("isAuthenticated()")
public class WorkbenchController {

    private final CourseScheduleService courseScheduleService;
    private final OrganizationHomePageService organizationHomePageService;


    @GetMapping("/future-schedule")
    @ApiOperation("未来一周的课表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "campusId", value = "校区id", paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "courseId", value = "课程id", paramType = "query", dataType = "string"),
    })
    public ResponseEntity<List<CourseScheduleDetailVO>> futureSchedule(String campusId, String courseId) {
        return ResultUtil.success(this.courseScheduleService.futureSchedule(campusId, courseId));
    }

    @PostMapping("briefing")
    @ApiOperation("今日概况")
    public ResponseEntity<OrganizationHomePageVO> getList(@RequestBody @Valid HomeDTO dto) {
        return ResultUtil.success(organizationHomePageService.getList(dto));
    }
}
